package com.shms.service.impl;

import java.util.List;

import com.shms.bean.GroupOfPoint;
import com.shms.bean.IndexParam;
import com.shms.dao.ShPointDao;
import com.shms.entity.ShGrade;
import com.shms.entity.ShPoint;
import com.shms.service.ShPointService;

/**
 * 文件名：ShBuildServiceImpl.java
 * 编写者：习孟冬
 * 创建时间：2013-1-6
 * 简要描述：
 * 
 */
public class ShPointServiceImpl implements ShPointService {
	private ShPointDao shPointDao;

	public List<ShPoint> queryShPoint(ShPoint shPoint) {
		return shPointDao.queryPointByGradeAndWeek(shPoint);
	}
	
	public List<ShPoint> queryShPointByBidAndHid(ShPoint shPoint) {
		return shPointDao.queryPointByBidAndHid(shPoint);
	}

	public List<ShPoint> queryAvgPointByHid(ShGrade shGrade) {
		return shPointDao.avgPointByHid(shGrade);
	}
	
	public GroupOfPoint queryPoint(GroupOfPoint groupOfPoint) {
		if (groupOfPoint.getType().equals("forward")) {
			int currentPage = groupOfPoint.getCurrentPage() - 2;
			groupOfPoint.setCurrentPage(currentPage);
		}
		return shPointDao.queryPoint(groupOfPoint);
	}
	
	public boolean batchDelete(Integer[] nos){
		return this.shPointDao.batchDelete(nos);
	}	
	
	public boolean savePoint(ShPoint shPoint) {
		boolean rtn = true;
		if (shPoint.getPid() == 0) {
			rtn = shPointDao.savePoint(shPoint);
		} else {
			rtn = shPointDao.updatePoint(shPoint);
		}
		return rtn;
	}
	
	public ShPoint queryById(ShPoint shPoint) {
		return shPointDao.queryById(shPoint);
	}
	
	public List<ShPoint> queryPointByExample(IndexParam indexParam) {
		return shPointDao.queryPointByExample(indexParam);
	}
	
	public void setShPointDao(ShPointDao shPointDao) {
		this.shPointDao = shPointDao;
	}
}
